export default {
  legend: {
    top: 'bottom',
    itemWidth: 10,
    itemGap: 25,
    itemHeight: 10,
    icon: 'rect',
    textStyle: {
      color: '#999'
    }
  },
  tooltip: {
    trigger: 'item'
  },
  title: {
    text: '',
    left: 'center',
    top: '40%',
    textStyle: {
      fontSize: 30,
      fontWeight: 'bold'
    },
    subtext: '',
    subtextStyle: {
      fontSize: 15,
      fontWeight: 'bold',
      color: '#999'
    }
  },
  color: ['#ff791a', '#ffc09e', '#7b5ccc', '#a28ddb', '#e4def5', '#ffe8bd'],
  toolbox: {
    feature: {
      dataView: {
        show: true,
        title: '表格数据',
        lang: ['表格数据', '关闭'],
        buttonColor: '#ff791a',
        readOnly: true,
        emphasis: {
          iconStyle: {
            borderColor: '#ff791a'
          }
        },
        optionToContent(opt) {
          const cols = ['行业', '数值']
          const data = opt.series[0].data
          const table = `<table class="dataViewTable">
              <thead>
                <tr class="dataViewTr">
                  ${cols
                    .map((item) => {
                      return `<td class="dataViewHead">${item}</td>`
                    })
                    .join('')}
                </tr>
              </thead>
              <tbody>
                ${data
                  .map((item) => {
                    return `<tr class="dataViewTr">
                    <td class="dataViewTd">${item.name}</td>
                    <td class="dataViewTd">${item.value}</td>
                  </tr>`
                  })
                  .join('')}
              </tbody>
            </table>`
          return table
        }
      }
    }
  },
  series: [
    {
      type: 'pie',
      radius: ['55%', '70%'],
      label: {
        lineHeight: 18,
        formatter({ name, value, percent }) {
          return `${name}(${value}): ${percent}%\n`
        }
      },
      labelLine: {
        length: 10
      },
      data: []
    }
  ]
}
